import { makeAutoObservable, autorun } from 'mobx'

class UserStore {

    constructor() {
        this.name = '<Enter your name>';
        this.age = 26
        this.onbroadingAge = 18;


        // use makeObservable or makeObservable to show the annotations explicitly
        makeAutoObservable(this, {}, {autoBind: true});
        // makeAutoObservable(this, {}, {autoBind : true});
        
        autorun(() => console.log(this)); 
    }

    // The following are actions:
    setName(name) {
        this.name = name;
        console.log(this.name);
    }    

    setAge(age) {
        this.age = age;
    }

    //computed
    get servedYears() {
        return this.age - this.onbroadingAge;
    }
}

export default UserStore;
  
